﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfUpdateRegionalAgent.aspx.cs" Inherits="msBsc.WebUi.ShpMana.wfUpdateRegionalAgent" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>修改区域代理</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/jqPlugin/hdfu/hdfu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/sReleaseForum.css" rel="stylesheet" />
    <link href="/jqPlugin/layer/skin/layer.css" rel="stylesheet" />
    <style type="text/css">
        /*头像*/
        .pf-edit-avatar {
            background: #000 none repeat scroll 10px 6px;
            bottom: 0;
            color: #e1d7ca;
            display: none;
            height: 21px;
            left: 0;
            line-height: 21px;
            opacity: 0.7;
            position: absolute;
            text-align: center;
            width: 100%;
        }

        .pf-avatar-box {
            display: inline-block;
            position: relative;
        }

        #logo_img_selected img {
            max-width: 245px;
        }
    </style>
</head>
<body>
    <div class="wf_all">
        <div class="main-container">
            <div class="main-Info" style="margin-bottom: 200px;">
                <div class="main-horizontal">
                    <div class="r_row">
                        <span class="control-span">用户头像<span class="required">*</span></span>
                        <div class="controls">
                            <div class="uploadbox" data-count="0" data-value="djack" style="display: block">
                                <div class="pf-avatar-box" id="imgHead">
                                    <img src="/UpLoad/Djack/djack.jpg" id="userPric" />
                                    <a class="pf-edit-avatar" href="javascript:;">编辑头像</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">证件副本<span class="required">*</span></span>
                        <div class="controls">
                            <div id="logo_img_selected">
                                <img id="uHeadImg" src="/themes/defaultimg/price_id.png" for="" />
                            </div>
                            <div style="padding: 5px;">
                                <a id="btnupImg" target="_self" value="添加证件" style="margin: 6px; cursor: pointer;" onclick="javascript:return false;">上传图片</a>

                            </div>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">证件类型<span class="required">*</span></span>
                        <div class="controls">
                            <select class="selArea" style="width: 200px;" id="credentialsType">
                                <option value="1">身份证</option>
                                <option value="2">护照</option>
                                <option value="3">驾照</option>
                            </select>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">证件号码:<span class="required">*</span></span><div class="controls">
                            <input type="text" id="credentialsNo" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">真实姓名:<span class="required">*</span></span><div class="controls">
                            <input type="text" id="realName" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">性别:<span class="required">*</span></span>
                        <div class="controls">
                            <input type="radio" id="Male" name="Gender" value="M" checked="checked" />
                            <label for="Male" class="label-gender">男</label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio" id="Female" name="Gender" value="F" />
                            <label for="Female" class="label-gender" style="margin-right: 60px;">女</label>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">生日:<span class="required">*</span></span><div class="controls">
                            <input type="text" id="birth" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">代理地区<span class="required">*</span></span>
                        <div class="controls">
                            <select class="selArea" id="selCountry">
                                <option value="0">请选择</option>
                                <option value="DF6723BE-A25C-4F77-BB49-A1662D3E6F2A">中国</option>
                                <option value="453370FE-8295-41EC-A41C-B6F650AD1B4C">亚洲</option>
                                <option value="927D5F28-C4FB-46A9-940C-B07DF0A04018">北美洲</option>
                                <option value="1FEAF456-7C76-41C8-A3D0-F9C12415A736">南美洲</option>
                                <option value="4E2B4524-E9CB-4E20-9224-E58EB636D1C7">非洲</option>
                                <option value="67FA6A8D-951C-4B53-AE1E-70DCB97E11DE">欧洲</option>
                                <option value="0B772F3D-D8F8-42E3-9019-81FE6F772236">大洋洲</option>
                            </select>
                            <select class="selArea" id="selCity">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="country_city_list" style="display: none">
                                <option value="0">请选择</option>
                                {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                       <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                                {{#} }}        
                            </xmp>
                            <select class="selArea" id="selDestination">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="city_des_list" style="display: none">
                               <option value="0">请选择</option>
                               {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                               {{#} }}
                            </xmp>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">座机电话:</span>
                        <div class="controls">
                            <input type="text" id="phone" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">手机电话:<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="mobile" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">QQ号码:</span>
                        <div class="controls">
                            <input type="text" id="qq" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">微信号码:</span>
                        <div class="controls">
                            <input type="text" id="wechatNo" class="input " />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">银行类型<span class="required">*</span></span>
                        <div class="controls">
                            <select style="width: 200px;" id="bankType">
                                <option value="-1">请选择</option>
                            </select>
                            <xmp id="svc_list_temp_bseBank" style="display: none">
                               <option value="-1">请选择</option>
                               {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                <option value="{{d.rows[i].BANK_ID}}">{{d.rows[i].BANK_NME}}</option>
                               {{#} }}
                            </xmp>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">卡号:<span class="required">*</span></span><div class="controls">
                            <input type="text" id="bankAccount" class="input " />
                        </div>
                    </div>

                    <div style="text-align: center; margin-top: 50px; width: 590px;">
                        <input type="button" onclick="saveData();" class="releaseBtn" style="margin-right: 20px;" value="保存" />
                    </div>
                </div>
            </div>
        </div>
        <div id="altContent">
        </div>
        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
        <script src="/jqPlugin/laydate/laydate.js"></script>
        <script src="/jqPlugin/layer/layer.min.js"></script>

        <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
        <script src="/themes/wStyle1/js/comm/DateInfo.js"></script>

        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>

        <script src="/jqPlugin/hdfu/hdfu.js"></script>

        <!--end JS引用-->
        <script type="text/javascript">
            //日期设置
            var start = {
                elem: '#birth',
                format: 'YYYY-MM-DD',
                min: '1099-06-16 23:59:59', //设定最小日期为当前日期
                max: laydate.now(), //最大日期
                istime: true,
                istoday: false,
                choose: function (datas) {
                }
            };
            laydate(start);

            $(function () {
                $(".pf-avatar-box").hover(function () {
                    $(".pf-edit-avatar").show();
                }, function () {
                    $(".pf-edit-avatar").hide();
                });
                //注册 文件上传
                $.ploadFile("kindeditor", function (script, textStatus) {
                    $.setUploadFile('btnupImg', { FileId: '', RelId: "", rType1: '0', rType2: '' }, function (data) {
                        if (data.url) {
                            $('#logo_img_selected').empty().html('<img alt="" src="' + data.url + '" for="' + data.url + '">');
                        }
                    });
                });


            });
            //注册 地区联动
            function SetAreaInfo() {
                $("#selCountry").change(function () {
                    $("#selCity").html("<option value='0'>请选择</option>");
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("countryId", $("#selCountry").val());
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                });

                $("#selCity").change(function () {
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                });
            }
            SetAreaInfo();

            //绑定银行
            function loadBankType() {
                var _opartParam = new jsonRow();
                _opartParam.AddCell("ACTION", "bankType");
                ajaxComm(_opartParam);
            }
            loadBankType();
            //加载数据
            var userid = GetQueryStr("userid");
            setTimeout(function () {
                if (IsNull(userid)) { return; }

                var _opartParam = new jsonRow();
                _opartParam.AddCell("userid", userid);
                _opartParam.AddCell("ACTION", "getInfo");
                ajaxComm(_opartParam);
            }, 300);

            //绑定数据
            var cityID = "", countryID = "", distinationID = ""
            function bindData(data) {
                var dataInfo = data.rows[0];
                $("#imgHead img").eq(0).attr("src", dataInfo.CUSTOMER_DEFAULT_PIC);
                $("#logo_img_selected img").eq(0).attr("for", dataInfo.DOCUMENT_IMAGE);
                $("#logo_img_selected img").eq(0).attr("src", dataInfo.DOCUMENT_IMAGE);

                $("#credentialsNo").val(dataInfo.CUSTOMER_CREDENTIALS_NO);
                $("#realName").val(dataInfo.CUSTOMER_BASEINFO_NAME);
                $("#credentialsType").val(dataInfo.CUSTOMER_CREDENTIALS_TYPE);
                if (dataInfo.CUSTOMER_BASEINFO_GENDER == "M") {
                    $("input[type=radio][name=Gender][value=M]").attr("checked", true);
                }
                else {
                    $("input[type=radio][name=Gender][value=F]").attr("checked", true);
                }
                
                var datatime = new Date(dataInfo.CUSTOMER_BASEINFO_BIRTH);
                $("#birth").val(datatime.getFullYear() + "-" + datatime.getMonth() + "-" + datatime.getDate());

                //国家
                cityID = dataInfo.AGENT_COUNTRY_ID;
                countryID = dataInfo.AGENT_CITY_ID;
                distinationID = dataInfo.AGENT_DISTINATION_ID;
                $("#selCountry").val(cityID);
                //城市
                var _opartParam = new jsonRow();
                _opartParam.AddCell("countryId", cityID);
                _opartParam.AddCell("cityId", countryID);
                _opartParam.AddCell("ACTION", "changeArea");
                ajaxComm(_opartParam);

                setTimeout(function () {
                    $("#selCity").val(countryID);
                    //地区
                    $("#selDestination").val(distinationID);
                },300);
                

                $("#mobile").val(dataInfo.CUSTOMER_BASEINFO_MOBILE);
                $("#phone").val(dataInfo.CUSTOMER_BASEINFO_PHONE);

                $("#qq").val(dataInfo.CUSTOMER_BASEINFO_QQ);
                $("#wechatNo").val(dataInfo.CUSTOMER_WECHAT_NO);
               
                $("#bankType").val(dataInfo.CUSTOMER_BANK_TYPE);
                $("#bankAccount").val(dataInfo.CUSTOMER_BANK_ACCOUNT);
            }


            //提交数据
            function saveData() {
                //头像验证
                var userPric = $("#imgHead img").eq(0).attr("src");
                if (userPric == "/UpLoad/Djack/djack.jpg" || IsNull(userPric)) {
                    layer.alert('请选择区域代理头像.', 3);
                    return;
                }
                //身份证验证
                var identityCard = $("#logo_img_selected img").eq(0).attr("for");
                if (IsNull(identityCard)) {
                    layer.alert('请添加区域代理身份证.', 3);
                    return;
                }
                //证件号码验证
                var credentialsNo = $("#credentialsNo").val();
                if (!yzNull("credentialsNo", "请添加身份证号码.")) { return; }
                //真实姓名验证
                var realName = $("#realName").val();
                if (!yzNull("realName", "请填写真实姓名.")) { return; }

                //性别验证
                var Gender = $("input[name='Gender']:checked").val();

                //生日验证
                var birth = $("#birth").val();
                if (!yzNull("birth", "请添加生日.")) { return; }

                //地区验证
                var selCountry = $("#selCountry option:selected").val();
                if (!yzFileNo("selCountry", "请选择国家.")) { return; }

                var selCity = $("#selCity option:selected").val();
                if (!yzFileNo("selCity", "请选择城市.")) { return; }

                var selDestination = $("#selDestination option:selected").val();
                if (!yzFileNo("selDestination", "请选择地区.")) { return; }
                //手机验证
                var mobile = $("#mobile").val();
                if (!yzNull("mobile", "请填写电话号码.") || !isZero(mobile)) {
                    layer.tips("请输入正确的手机号码.", $("#mobile"), { guide: 0, time: 3 }); return;
                    return;
                }

                //银行类型验证
                var bankType = $("#bankType option:selected").val();
                if (!yzFileNo("bankType", "请选择银行类型.")) { return; }

                //卡号验证
                var bankAccount = $("#bankAccount").val();
                if (!yzNull("bankAccount", "请填写银行卡号.")) { return; }

                //QQ
                var QQ = $("#qq").val();
                if (!IsNull(QQ) && !isQQ(QQ)) {
                    $("#qq").focus();
                    layer.tips("QQ格式不正确.", $("#qq"), { guide: 0, time: 3 }); return;
                }
                //微信
                var wechatNo = $("#wechatNo").val();
                if (!IsNull(wechatNo) && !isEnLength(wechatNo, 0, 30)) {
                    layer.tips("微信最大长度为30个字符,中文算两个字符.", $("#wechatNo"), { guide: 0, time: 3 }); return;

                }
                layer.load('正在提交,请稍后', 2);
                //提交
                var _opartParam = new jsonRow();
                _opartParam.AddCell("userid", userid);
                
                _opartParam.AddCell("userPric", userPric);
                _opartParam.AddCell("identityCard", identityCard);
                _opartParam.AddCell("credentialsNo", credentialsNo);
                _opartParam.AddCell("realName", realName);
                _opartParam.AddCell("Gender", Gender);
                _opartParam.AddCell("birth", birth);

                _opartParam.AddCell("selCountry", selCountry);
                _opartParam.AddCell("selCity", selCity);
                _opartParam.AddCell("selDestination", selDestination);

                _opartParam.AddCell("mobile", mobile);
                _opartParam.AddCell("bankType", bankType);
                _opartParam.AddCell("bankAccount", bankAccount);

                _opartParam.AddCell("phone", $("#phone").val());
                _opartParam.AddCell("qq", QQ);
                _opartParam.AddCell("wechatNo", wechatNo);

                _opartParam.AddCell("credentialsType", $("#credentialsType").val());


                _opartParam.AddCell("ACTION", "save");
                ajaxComm(_opartParam);
            }


            //不能为空 验证
            function yzNull(inputId, message) {
                var txtInfo = $.trim($("#" + inputId).val());
                if (IsNull(txtInfo)) {
                    $("#" + inputId).focus();
                    layer.tips(message, $("#" + inputId), { guide: 0, time: 3 });
                    return false;
                }
                return true;
            }
            //下拉框 验证
            function yzFileNo(inputId, message) {
                var txtInfo = $.trim($("#" + inputId + " option:selected").val());
                if (txtInfo == "0" || txtInfo == "-1") {
                    $("#" + inputId).focus();
                    layer.tips(message, $("#" + inputId), { guide: 0, time: 3 });
                    return false;
                }
                return true;
            }

            //成功
            function success() {
                layer.alert('添加成功', 1);
                setTimeout(function () {
                    location.href = location.href;
                }, 2000);
            }

        </script>
    </div>
</body>
</html>
